home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -serious- / programming / other / tandem / projects / asmfiles / test01.asm < prev    next >
Assembly Source File  |  1999-09-06  |  13KB  |  713 lines

  1. * Quick test of all pseudo ops - subject to detailed testing.
  2. * After assembly, sinle step once to relocate relocs in line labelled
  3. *   ldc3, to see they relocate correctly
  4.  
  5.  rts
  6.  
  7. * not tested herein
  8. *  incbin
  9. *  ibytes
  10. *  xdef  global public
  11. *  xref
  12.  
  13. * addsym - not supported
  14.  
  15. * align
  16. lalign1 align 8  ;should make rel addr 0008
  17. lalign2 align 16 ;should make rel addr 0010
  18. lalign3 dc.b 1   ;should make rel addr 0011
  19. lalign4 align 2  ;should make rel addr 0012
  20. lalign5 align 4  ;should make rel addr 0014
  21. lalign6 align 4  ;should do nothing
  22. lalign7 set lalign1 ;s/be rel 0008
  23. lalign7 set lalign2 ;s/be rel 0010
  24. lalign7 set lalign3 ;s/be rel 0011
  25. lalign7 set lalign4 ;s/be rel 0012
  26. lalign7 set lalign5 ;s/be rel 0014
  27. lalign7 set lalign6 ;s/be rel 0014
  28.  
  29. * ascii
  30.  ascii 'a','bc',''     ;61 6263 -
  31.  ascii '''"''',"""'""" ;272227 222722
  32.  ascii '','ab
  33.  ds.w 0                ;align - prev 6162
  34.  
  35. * bdebugarg - not supported
  36.  
  37. * bitstream
  38.  bitstream 10111101000111 ;BD1C
  39.  bitstream '1',"0",1      ;A0
  40.  ds.w 0                   ;align
  41.  
  42. * blk see DCB
  43.  
  44. * bopt - not supported
  45.  
  46. * bss - not supported
  47.  
  48. * cargs
  49.  cargs #16,ca_1.w,ca_2,ca_3.b,ca_4.l,ca_sizeof
  50. ca set ca_1      ;0010
  51. ca set ca_2      ;0012
  52. ca set ca_3      ;0014
  53. ca set ca_4      ;0016 (not 0015)
  54. ca set ca_sizeof ;001A
  55.  
  56. * clrfo clrrs clrso - see fo
  57.  
  58. * cmacro - Tandem treats same as MACRO
  59. lcma1 cmacro
  60.  rts
  61.  endm
  62. lcma2 camcro
  63.  rts
  64.  endm
  65.  lcma1       ;4E75
  66.  lcma2       ;4E75
  67.  rts         ;4E75
  68.  
  69. * cnop
  70. lcno0 cnop 0,16   ;makes rel 0010
  71.  cnop 0,16   ;does nothing
  72. lcno1 cnop 1,2 ;makes 0011
  73. lcno2 cnop 2,4 ;makes 0012
  74. lcno3 cnop 3,8 ;makes 0013
  75. lcno4 cnop 2,8 ;makes 001A
  76. lcno5 cnop 0,2 ;makes 001A
  77. lcno set lcno0 ;0010
  78. lcno set lcno1 ;0011
  79. lcno set lcno2 ;0012
  80. lcno set lcno3 ;0013
  81. lcno set lcno4 ;001A
  82. lcno set lcno5 ;001A
  83.  
  84. * code cseg - not supported
  85.  
  86. * cstring
  87.  ascii 'a','bc',''     ;6100 626300 00
  88.  ascii '''"''',"""'""" ;27222700 22272200
  89.  ascii 'ab
  90.  ds.w 0                ;align - prev 616200
  91.  
  92. * data - not supported
  93.  
  94. * db nb pb sb ub - treated as dc.b
  95. * dl nl pl sl ul - treated as dc.l
  96. * dw nw pw sw uw - treated as dc.w
  97.  dc.l 0,-1,+1,1,$FF ;00FF0101FF
  98.  ds.w 0   ;00 (normalises)
  99.  db 0     ;00
  100.  nb -1    ;FF
  101.  pb +1    ;01
  102.  sb 1     ;01
  103.  ub 255   ;FF
  104.  
  105. ldb1 dw 0 ;000000 (normalises)
  106.  nw -1    ;FFFF
  107.  pw +1    ;0001
  108.  sw 1     ;0001
  109.  uw 65535 ;FFFF
  110.  dl 0     ;00000000
  111.  nl -1    ;FFFFFFFF
  112.  pl +1    ;00000001
  113.  sl 1     ;00000001
  114.  ul $FFFFFFFF ;FFFFFFFF
  115. ldb set ldb1  ;s/be even
  116.  
  117. * dc - n.b. check that ldc2 addrs reloc correctly after step
  118.  dc.b 0,'a','''','"',"'","""",'a''b' ;306127 222722 612762
  119. ldc1 dc.w 'AB','''''','B',$1234      ;4142 2727 4200 1234
  120.  dc.l 'ABCD','abc'                   ;41424344 61626300
  121. ldc3 dc.l ldc1,ldc2                  ;.....
  122. ldc2
  123. ldc set ldc1   ;s/be even (asmlist addr+1)
  124.  
  125. * dcb (and blk dsb)
  126.  dcb.b 5,'A' ;AAAAA
  127. ldcb1 dcb.w 0,'A' ;0000
  128.  dcb.w 2,'AB
  129.  dcb.l 1,'ABCD' ;41424344, prev 41424142
  130. ldcb2 equ ldcb1 ;s/be even
  131.  blk 5,'A' ;4141414141
  132.  dsb 5,'A' ;4141414141
  133.  
  134. * debug - not supported
  135.  
  136. * doscmd - not supported
  137.  
  138. * ds - can also have dcb syntax if 2 addresses
  139.  
  140.  ds.b 0      ;-
  141.  ds.b 1      ;00
  142. lds1 ds.w 0  ;00 0000 (normalises)
  143.  ds.w 1      ;0000
  144. lds set lds1 ;s/be even
  145.  
  146. * dsb - see dcb
  147.  
  148. * dsbin - not supported
  149.  
  150. * dseg - not supported
  151.  
  152. * dstring - not supported
  153.  
  154. * else - not supported
  155.  
  156. * elseif - not supported
  157.  
  158. * end - remove ; here to check assembly ends here
  159.  
  160. ; end
  161.  
  162. * endif same as endc
  163.  
  164. * endc - see ifc
  165.  
  166. * endm - see macro
  167.  
  168. * equ
  169. lequ1 equ $12345678
  170.  move.l #lequ1,d0
  171. lequ2 equ *
  172.  move.l #lequ2,d0
  173.  
  174. * equr
  175. leqr1 equr d0
  176. leqr2 equr leqr1
  177.  tst d0
  178.  tst leqr1
  179.  tst leqr2
  180.  
  181. * even
  182.  dc.b $80
  183. leven1 even      ;should assemble a null
  184. level2 even      ;should do nothing
  185. leven3 equ leven1 ;s/be even
  186. leven4 equ leven2 ;s/be same as lenev3
  187.  
  188. * exeobj - tandem always does
  189.  exeobj
  190.  
  191. * fail see last line
  192.  
  193. * filecom - not supported
  194.  
  195. * fo clrfo foreset foset foval setfo
  196. * rs clrrs rsreset rsset rsval setrs
  197. * so clrso soreset soset soval setso
  198.  foreset
  199. lfo0 fo 1
  200.  rsreset
  201. lrs0 rs 1
  202.  soreset
  203. lso0 so 1
  204.  clrfo
  205. lfo6 fo 1
  206.  clrrs
  207. lrs6 rs 1
  208.  clrso
  209. lso6 so 1
  210.  foval 16
  211. lfo1 fo.w 1
  212. lfo2 fo 1
  213. lfo3 fo.l 1
  214. lfo4 fo.b 3
  215. lfo5 fo 1
  216.  rsval 16
  217. lrs1 rs.w 1
  218. lrs2 rs 1
  219. lrs3 rs.l 1
  220. lrs4 rs.b 3
  221. lrs5 rs 1
  222.  soval 16
  223. lso1 so.w 1
  224. lso2 so 1
  225. lso3 so.l 1
  226. lso4 so.b 3
  227. lso5 so 1
  228.  foval 8
  229. lfo7 fo 1
  230.  soval 8
  231. lso7 so 1
  232.  rsval 8
  233. lrs7 rs 1
  234. lfo set lfo0 ;0000
  235. lfo set lfo6 ;0000
  236. lfo set lfo1 ;0010
  237. lfo set lfo2 ;000E
  238. lfo set lfo3 ;000A
  239. lfo set lfo4 ;0006
  240. lfo set lfo5 ;0002 (not 0003)
  241. lrs set lrs0 ;0000
  242. lrs set lrs6 ;0000
  243. lrs set lrs1 ;0010
  244. lrs set lrs2 ;0012
  245. lrs set lrs3 ;0014
  246. lrs set lrs4 ;0018
  247. lrs set lrs5 ;001C (not 001B)
  248. lso set lso0 ;0000
  249. lso set lso6 ;0000
  250. lso set lso1 ;0010
  251. lso set lso2 ;0012
  252. lso set lso3 ;0014
  253. lso set lso4 ;0018
  254. lso set lso5 ;001C (not 001B)
  255.  
  256. * format - Tandem ignores
  257.  FORMAT
  258.  
  259. * global - see xdef
  260.  
  261. * ibytes - test separately
  262.  
  263. * idnt identify
  264.  
  265. * ifc ifd ifeq ifge ifgt ifle iflt ifmacrod ifmacrond ifnc icnd
  266. * illegal
  267.  
  268. * incbin - test separately
  269.  
  270. * incdir
  271. * include
  272. * incpath
  273.  
  274. * istring - not supported
  275.  
  276. * linkobj - tandem always does
  277.  linkobj
  278.  
  279. * list
  280. * listfile
  281. * llen
  282. * macro
  283. * mask2
  284. * mexit
  285. * mc68000 mc68010 mc68020 mc68030 mc68040 mc68060 mc68881 mc68882
  286.  
  287. * nb nl nw - see pb
  288.  
  289. * noformat - Tandem ignores
  290.  NOFORMAT
  291.  
  292. * nol nolist
  293. * noobj
  294. * nopage
  295. * objfile
  296.  
  297. * odd
  298. lodd1 odd     ;should assemble a null
  299. lodd2 odd    ;should do nothing
  300. lodd3 ds.w 0 ;re-align
  301. lodd4 equ lodd1 ;s/be rel addr shown beside lodd1+2
  302. lodd5 equ lodd2 ;s/be same as lodd4
  303. lodd6 equ *     ;s/be lodd4+1
  304.  
  305. * offset
  306. * org
  307. * output
  308. * pad - not supported
  309.  
  310. * page
  311.  
  312. * pb pl pw - see db
  313.  
  314. * plen
  315. * printx
  316.  
  317. * pstring
  318.  ascii 'a','bc',''     ;0161 026263 00
  319.  ascii '''"''',"""'""" ;03272227 03222722
  320.  ascii 'ab
  321.  ds.w 0                ;align - prev 036162
  322.  
  323. * public - see xdef
  324.  
  325. * pure
  326.  
  327. * quad
  328.  dc.b -1
  329. lquad1 quad      ;should make rel addr xxx0
  330. lquad2 quad      ;should do nothing
  331. lquad3 equ lquad1 ;s/be xxx0
  332. lquad4 equ lquad2 ;s/be same as lquad3
  333.  
  334. * reg
  335. * repeat rept
  336. * rorg
  337. * rs rsreset rsset rsval - see fo
  338.  
  339. * sb sl sw - see db
  340.  
  341. * section
  342. * set
  343. * setfo setrs setso - see fo
  344. * smalldata
  345. * so soreset soset soval - see fo
  346. * spc
  347. * sprintx
  348. * super
  349. * sym - not supported
  350. * trashreg
  351. * ttl
  352.  
  353. * ub ul uw - see db
  354.  
  355. * xdef global public - not tested herein
  356.  
  357. * xref - not tested herein
  358.  
  359.  
  360.  
  361.  
  362.  
  363. * test macro assembly
  364.  
  365. fred: macro    ;test \0 assembly
  366.  move.\0 \1,\2 ;}should assemble
  367.  move.l \1,\2  ;}same as each other
  368.  endm
  369.  
  370.  fred.l $1234,$4321
  371.  rts
  372.  
  373. free: macro    ;test \@ assembly
  374.  moveq #20,d0
  375.  moveq #0,d1
  376. L\@:
  377.  addq.w #1,d1
  378.  dbra d0,L\@   ;s/be same as dbra d0,jim below
  379.  nop
  380.  endm
  381.  free
  382.  moveq #20,d0
  383.  moveq #0,d1
  384. jim:
  385.  addq.w #1,d1
  386.  dbra d0,jim
  387.  rts
  388.  
  389. * test IFcc statements        Yes line 0
  390.  moveq #1,d0 ;                Yes line 1
  391.  ifeq 0      ;#1              Yes line 2
  392.  moveq #2,d0 ;true 1 (level 1) Yes line 3
  393.  endc        ;#1               Yes line 4
  394.  ifne 0      ;#2               } should
  395.  moveq #3,d0 ;false (level 1)  } not be
  396.  endc        ;#2               } in mc
  397.  moveq #4,d0 ;                 Yes line 5
  398.  ifne 1      ;#3>1             Yes line 6
  399.  moveq #5,d0 ;true 2 (level 1) Yes line 7
  400.  ifgt -1     ;#4>2             }
  401.  moveq #6,d0 ;false (level 2)  } should
  402.  ifeq 0      ;#5>3             } not be
  403.  moveq #7,d0 ;false (level 3)  } in mc
  404.  endc        ;#5>2             }
  405.  endc        ;#4>1             }
  406.  iflt -1     ;#6>2             Yes line 8
  407.  moveq #7,d0 ;true 3 (level 2) Yes line 9
  408.  endc        ;#6>1             Yes line 10
  409.  endc        ;#3>0             Yes line 11
  410.  moveq #8,d0 ;                 Yes line 12
  411.  rts         ;                 Yes line 13
  412.  
  413. * test endcc with mexit
  414. frex: macro
  415.  moveq #0,d0
  416.  ifne 0       ;#1>1  }should
  417.  mexit        ;false }not be
  418.  endc         ;#1>0  }in list
  419.  moveq #1,d0
  420.  ifeq 0       ;#2>1
  421.  mexit        ;true
  422.  endc         ;#2>0
  423.  moveq #3,d0
  424.  endm
  425.  nop
  426.  frex
  427.  nop
  428.  rts
  429.  
  430. * Test INCLUDE
  431.  
  432.  include 'incall.i'
  433.  rts
  434.  
  435. * test DS and DC
  436.  bra.s harry
  437.  dc.b 'abcd'
  438. frey:
  439.  ds.b 1
  440.  ds.w 0               ;(should normalise)
  441.  dc.b 1,2,'abcd',3*4
  442.  dc.w $1234,$4321     ;(should normalise)
  443.  dc.l frey,harry,$12345678
  444. harry:
  445.  rts
  446.  
  447. * test EQUR
  448. jack: equr d4
  449. bill: equr a7
  450. john: equr jack
  451.  
  452.  moveq #0,d4       ;7800
  453.  moveq #0,jack     ;7800
  454.  moveq #0,john     ;7800
  455.  move.l d0,-(a7)   ;2F00
  456.  move.l d0,-(bill) ;2F00
  457.  
  458. * test REG
  459. hugh: reg d0-d1/a1-a3
  460. jane: reg hugh
  461.  
  462.  movem.l d0-d1/a1-a3,-(a7) ;48E7C070
  463.  movem.l hugh,-(a7)        ;48E7C070
  464.  movem.l jane,-(a7)        ;47E7C070
  465.  movem.l (a7)+,d0-d1/a1-a3 ;4CDF0E03
  466.  movem.l (a7)+,hugh        ;4CDF0E03
  467.  movem.l (a7)+,jane        ;4CDF0E03
  468.  
  469. joan: reg d1-jack/bill/a2-a3
  470.  
  471.  movem.l d1-d4/a7/a2-a3,-(a4) ;48E47831
  472.  movem.l joan,-(a4)           ;48E47831
  473.  
  474. ^^^^
  475.  
  476.  
  477.  
  478. * try local labels
  479. bilp:
  480. .bill:
  481. 12$: moveq #20,d0
  482.  bra 12$
  483.  bra .bill
  484. frez:
  485. .jack:
  486. 12$: moveq #20,d0
  487.  bra 12$
  488.  bra .jack
  489.  
  490. * test selection of .W/.L for addr mode 15,16
  491.  nop
  492. frew: equ $12345678
  493. bilq: equ $1234
  494. jacl:
  495.  
  496.  move.l $4,d0   ;20380004
  497.  move.l frew,d0 ;203912345678
  498.  move.l bilq,d0 ;20381234
  499.  move.l jacl,d0 ;20390000091C
  500.  move.l $4.W,d0 ;20380004
  501.  move.l $4.L,d0 ;203900000004
  502.  rts            ;4E75
  503.  
  504.  END
  505.  
  506. * forward references in expressions
  507.  move.l #frad,d0    ;203C12345678
  508.  move.l #jpan,d0    ;203C00000014
  509.  move.w #jock,d0    ;303C1234
  510.  move.b #jill,d0    ;103C0012
  511. jpan:
  512.  rts                ;4E75
  513.  
  514. frad: equ $12345678
  515. jock: equ $1234
  516. jill: equ $12
  517.  
  518. * forward references in bra relative
  519.  dbra d0,jpan    ;51C8FFFC
  520.  bra jpan        ;60F8
  521.  bra.s sue       ;6016
  522.  bra.w sue       ;60000014
  523.  bra.l sue       ;60FF00000010
  524.  bsr.s sue       ;610A
  525.  bsr sue         ;61000008
  526.  dbra d0,sue     ;51C80004
  527.  nop             ;4E71
  528. sue:
  529.  
  530. * SET items in expressions with fwd refs
  531. ken: set 1
  532.  move.l #ken+jvhn,d0 ;203C00000004
  533. ken: set 2
  534.  move.l #ken+jvhn,d0 ;203C00000005
  535.  nop                 ;4E71
  536. jvhn: equ 3
  537.  
  538. * doll in expressions with fwd refs
  539.  move.l #june-*,d0   ;203C00000008
  540.  nop                 ;4E71
  541. june:
  542. * try MACRO and IFcc
  543.  
  544. fred: macro    ;test synthetic labels
  545.  moveq #20,d0
  546.  moveq #0,d1
  547. L\@:           ;assemble as L_000
  548.  addq.w #1,d1
  549.  dbra d0,L\@   ;s/be same as dbra d0,jim blow
  550.  nop
  551.  endm
  552.  
  553.  fred ;70147200524151C8FFFC4E71
  554.  moveq #20,d0  ;7014
  555.  moveq #0,d1   ;7200
  556. jim:
  557.  addq.w #1,d1  ;5241
  558.  dbra d0,jim   ;51C8FFFC
  559.  rts           ;4E75
  560.  
  561. * test IFcc statements
  562. * only true1,true2 & true3 should assemble
  563.  moveq #1,d0 ;7001
  564.  ifeq 0      ;#1
  565.  moveq #2,d0 ;true 1 (level 1) 7002
  566.  endc        ;#1
  567.  ifne 0      ;#2
  568.  moveq #3,d0 ;false (level 1)
  569.  endc        ;#2
  570.  moveq #4,d0 ;7004
  571.  ifne 1      ;#3>1
  572.  moveq #5,d0 ;true 2 (level 1) 7005
  573.  ifgt -1     ;#4>2
  574.  moveq #6,d0 ;false (level 2)
  575.  ifeq 0      ;#5>3
  576.  moveq #7,d0 ;false (level 3)
  577.  endc        ;#5>2
  578.  endc        ;#4>1
  579.  iflt -1     ;#6>2
  580.  moveq #7,d0 ;true 3 (level 2) 7007
  581.  endc        ;#6>1
  582.  endc        ;#3>0
  583.  moveq #8,d0 ;7008
  584.  rts         ;4E75
  585.  
  586. * test ifcc with mexit
  587. bill: macro
  588.  moveq #0,d0
  589.  ifne 0       ;#1>1
  590.  mexit        ;false
  591.  endc         ;#1>0
  592.  moveq #1,d0
  593.  ifeq 0       ;#2>1
  594.  mexit        ;true
  595.  endc         ;#2>0
  596.  moveq #3,d0
  597.  endm
  598.  
  599.  nop  ;4E71
  600.  bill ;7000 7001
  601.  nop  ;4E71
  602.  rts  ;4E75
  603.  
  604. * test DS and DC
  605.  bra.s harry ;602E
  606. jack:
  607.  dc.b 'abcd' ;61626364
  608.  ds.b 1      ;00
  609.  ds.w 0      ;00
  610.  dc.b 1,2,'ab''d',3*4 ;0102616227640C
  611.  dc.w $1234,$4321     ;12344321
  612.  dc.l jack,harry,$12345678 ;32.l,60.l,12345678
  613.  dcb.b 3,$AA ;AAAAAA
  614.  dcb 2,$1234 ;0012341234
  615.  dcb.l 2,$BADFACED ;BADFACEDBADFACED
  616. harry:
  617.  rts         ;4E75
  618.  
  619. * test local labels
  620. boll:
  621. .boll:
  622. 12$: moveq #20,d0 ;7014
  623.  bra 12$   ;60FC
  624.  bra .boll ;60FA
  625. frad:
  626. .jeck:
  627. 12$: moveq #20,d0 ;7014
  628.  bra 12$   ;60FC
  629.  bra .jeck ;60FA
  630.  
  631. * forward references in expressions
  632.  move.l #ferd,d0    ;203C12345678
  633.  move.l #joon,d0    ;203C000000AC
  634.  move.w #juck,d0    ;303C1234
  635.  move.b #jill,d0    ;103C0012
  636. joon:
  637.  rts                ;4E75
  638. ferd: equ $12345678
  639. juck: equ $1234
  640. jill: equ $12
  641.  
  642. * forward references in bra relative
  643.  dbra d0,joon    ;51C8FFFC
  644.  bra joon        ;60F8
  645.  bra.s sue       ;6016
  646.  bra.w sue       ;60000014
  647.  bra.l sue       ;60FF00000010
  648.  bsr.s sue       ;610A
  649.  bsr sue         ;61000008
  650.  dbra d0,sue     ;51C80004
  651.  nop             ;4E71
  652. sue:
  653.  
  654. * SET items in expressions with fwd refs
  655. ken: set 1
  656.  move.l #ken+jon,d0 ;203C00000004
  657. ken: set 2
  658.  move.l #ken+jon,d0 ;203C00000005
  659.  nop                ;4E71
  660. jon: equ 3
  661.  
  662. * doll in expressions with fwd refs
  663.  move.l #june-*,d0   ;203C00000008
  664.  nop                 ;4E71
  665. june:
  666.  
  667. * test \@ invocation
  668.  
  669. derf: macro
  670.  move.l #'\@',d0
  671.  endm
  672.  
  673. llib: macro
  674.  move.l #'\@',d0
  675.  derf
  676.  move.l #'\@',d0
  677.  endm
  678.  
  679. cazz: macro
  680.  nop
  681.  endm
  682.  
  683.  llib ;203C5F303032,3,2
  684.  cazz ;4E71
  685.  llib ;203C5F303034,5,4
  686.  rts  ;4E75
  687.  
  688. * unsupported opcodes - all should return errors
  689.  ADDSYM
  690.  BDEBUG
  691.  BOPT
  692.  BSS
  693.  CODE
  694.  CSEG
  695.  DEBUG
  696.  DOSCMD
  697.  DSBIN
  698.  DSEG
  699.  DSTRING
  700.  ELSE
  701.  ELSEIF
  702.  FILECOM
  703.  ISTRING
  704.  PAD
  705.  SYM
  706.  
  707. * remove ; here to premit END to appear - will zap FAIL hereafter
  708. Endhere:
  709. ; END
  710.  
  711. * fail
  712.  FAIL ; causes fatal error
  713.